package com.wk.common;

import java.io.Serializable;

public class R<T> implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8022448057854528843L;

	public static final int NO_LOGIN = -1;

	public static final int SUCCESS = 0;

	public static final int FAIL = 1;

	public static final int NO_PERMISSION = 2;
	
	public static final String SUCCESS_QUERY = "查询成功";
	public static final String SUCCESS_SUBMIT = "提交成功";

	private String msg = "success";

	private int code = SUCCESS;

	private T data;

	public R(int code,String msg) {
		this.code = code;
		this.msg = msg;
	}

	public R(int code,String msg,T data) {
		this(code,msg);
		this.data = data;
	}

	public R(T data, String msg) {
		super();
		this.data = data;
		this.msg = msg;
	}

	public R(Throwable e) {
		super();
		this.msg = e.getMessage();
		this.code = FAIL;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}
}
